package com.hst.capacity.application.jpush.model.request;


import com.alibaba.fastjson2.JSONObject;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;

@Setter
public class JPushMessage {
    private String msgContent;
    private String title;
    private String contentType;
    private JSONObject extras;

    public JSONObject getParam(){
        JSONObject jsonObject=new JSONObject();

        if(StringUtils.isBlank(msgContent)){
            return null;
        }

        jsonObject.put("msg_content",msgContent);

        if(StringUtils.isNotBlank(title)){
            jsonObject.put("title",title);
        }
        if(StringUtils.isNotBlank(contentType)){
            jsonObject.put("content_type",contentType);
        }
        if(extras!=null){
            jsonObject.put("extras",extras);
        }

        JSONObject param=new JSONObject();

        param.put("message",jsonObject);

        return param;
    }

}
